package holdemdealer.ws;

import card.entity.Card;
import deck.Deck;
import handflow.HandStatus;
import holdemdealer.cardchecker.HandFlow;
import holdemdealer.players.PlayersList;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@Stateless
@WebService(portName = "Dealer", serviceName = "DealerService", targetNamespace = "http://holdem.home/wsdl", endpointInterface = "holdemdealer.ws.DealerEndpoint")
public class DealerService implements DealerEndpoint {

    @Override
    public void addPlayer(String playerId) {
        PlayersList.instance().addPlayer(playerId);
    }

    @Override
    public HandStatus getHandStatus() {
        return HandFlow.instance().getHandStstus();
    }

    @Override
    public Deck getDeck() {
        return HandFlow.instance().getDeck();
    }

    @Override
    public void playerAction() {
    }

    @Override
    public void getPocketCards() {
        if (HandFlow.instance().getHandStstus() == HandStatus.PREFLOP) {
        }
    }

    @Override
    public List<Card> getFiveCards() {
        ArrayList<Card> resultList = new ArrayList<Card>();
        Deck deck = HandFlow.instance().getDeck();
        for (int i = 0; i < 5; i++) {
            resultList.add(deck.getCards().get(i));
        }
        return resultList;
    }

    public static void main(String[] args) {
        Endpoint.publish("http://localhost:8080/WS/dealer", new DealerService());

    }
}
